package com.stylefeng.guns.core.util.clm;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.stylefeng.guns.config.properties.GunsProperties;

/**
 * Training接口工具类
 * @author 
 *
 */
public class AdminTools {
	private static final Logger log = Logger.getLogger(AdminTools.class);
	/*public final static Map<String, String> SiteIdMap = new HashMap<String, String>() {  
        {  
            put("001", "http://live.wbljy.cn");
            put("002", "http://live.yceduyun.com");
            put("003", "http://live.lseduyun.com");
            put("004", "http://live.tyskpxyez.cn");
            put("005", "http://saas5.live.hseduyun.net");
           
        }  
    };*/
    
	public final static Map<String, String> SiteIdMap = new HashMap<String, String>() {  
        {  
            put("001", "http://saas1.live.hseduyun.net");
            put("002", "http://saas2.live.hseduyun.net");
            put("003", "http://saas3.live.hseduyun.net");
            put("004", "http://saas4.live.hseduyun.net");
            put("005", "http://saas5.live.hseduyun.net");
            put("007", "http://saas7.live.hseduyun.net");
           
        }  
    };
	
	/*public final static Map<String, String> SiteIdMap = new HashMap<String, String>() {  
        {  
            put("001", "http://saas1.live.hseduyun.net:9092");
            put("002", "http://saas2.live.hseduyun.net:9092");
            put("003", "http://saas3.live.hseduyun.net:9092");
            put("004", "http://saas4.live.hseduyun.net:9092");
            put("005", "http://saas5.live.hseduyun.net:9092");
           
        }  
    };*/
    
    //后台域名对应站点id
    public final static Map<String, String> adminMap = new HashMap<String, String>() {  
        {  
            put("admin.live.hseduyun.net", "001");
            put("saas7.admin.live.hseduyun.net", "007");
        }  
    };
    
   /* public final static Map<String, String> adminMap = new HashMap<String, String>() {  
        {  
            put("admin.live.hseduyun.net", "001");
           
        }  
    };*/
    
   /* public final static Map<String, String> adminMap = new HashMap<String, String>() {  
        {  
            put("admin.live.wbljy.cn", "001");
            put("admin.live.yceduyun.com", "002");
           
        }  
    };*/
  
	/**
	 * 根据RoomID获取课堂信息
	 * @param roomId
	 * @return
	 * @throws Exception
	 */
	public static String getLookUrlByRoomId(String roomId,String siteId,String userId)throws Exception{
		if(StringUtils.isBlank(roomId))
			return null;
		Map<String, String> map=new HashMap<String, String>();
		map.put("userId", userId);
		map.put("roomId", roomId);
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.ROOM_LOOK_URL,map);
		
		return result;
	}
	
	/**
	 * 更改课程卡图片
	 * @param roomId
	 * @return
	 * @throws Exception
	 */
	public static String updateImageUrl(String userId,String uploadUrl,String siteId)throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("userId", userId);
		map.put("uploadUrl", uploadUrl);
		
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.UPDATE_ROOM_IMAGE,map);
		return result;
	}
	
	/**
	 * 获取省
	 * @param roomId
	 * @return
	 * @throws Exception
	 */
	@Test
	public static String findProvinceList(String provinceCode,String siteId)throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("provinceCode", provinceCode);
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.PROVINCE,map);
		log.info(result);
		return result;
	}
	
	/**
	 * 获取市
	 * @param roomId
	 * @return
	 * @throws Exception
	 */
	public static String findCityList(String provinceCode,String siteId)throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("provinceCode", provinceCode);
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.CITY,map);
		return result;
	}
	
	/**
	 * 获取区、县
	 * @param roomId
	 * @return
	 * @throws Exception
	 */
	public static String findDiscList(String cityCode,String siteId)throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("cityCode", cityCode);
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.DISC,map);
		
		return result;
	}
	
	/**
	 * 获取学校
	 * @param roomId
	 * @return
	 * @throws Exception
	 */
	public static String findSchoolList(String areaCode,String type,String siteId)throws Exception{
		
		Map<String, String> map=new HashMap<String, String>();
		map.put("areaCode", areaCode);
		map.put("type", type);//0代表省，1代表市，2代表县/区
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.SCHOOL,map);
		return result;
	}
	
	/**
	 * 获取所有科目
	 * @param siteId
	 * @return
	 * @throws Exception
	 */
	public static String findAllSubject(String siteId)throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("siteId", siteId);
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.ALL_SUBJECT,map);
		return result;
	}
	
	/**
	 * 获取老师信息
	 * @param siteId
	 * @param teacherId
	 * @return
	 * @throws Exception
	 */
	public static String getTeacherBySiteIdTeacherId(String siteId,String teacherId)throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("siteId", siteId);
		map.put("teacherId", teacherId);
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.GET_TEACHER,map);
		return result;
	}
	
	/**
	 * 获取老师信息
	 * @param siteId
	 * @param AccountId
	 * @return
	 * @throws Exception
	 */
	public static String getTeacherBySiteIdAccountId(String siteId,String accountId)throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("siteId", siteId);
		map.put("accountId", accountId);
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.GET_TEACHER_BY_ACCOUNTID,map);
		return result;
	}
	
	/**
	 * 获取教师科目
	 * @param teacherId
	 * @param siteId
	 * @return
	 * @throws Exception
	 */
	public static String getSubjectByTeacherId(String teacherId,String siteId)throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("siteId", siteId);
		map.put("teacherId", teacherId);
		String result = HttpTools.sendHttpClientGet(SiteIdMap.get(siteId)+AdminConstant.GET_TEACHER_SUBJECT,map);
		return result;
	}
	
}